/*
 *  Copyright 2009 Advanced Industrial Science and Technology (AIST).
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

/*! \file
 *  \brief
 */

#pragma once

namespace thrust
{
  template<typename T>
  struct numeric_limits
  {
    __host__ __device__
    static T min() throw() { return static_cast<T>(0);}
    __host__ __device__
    static T max() throw() { return static_cast<T>(0);}
  };
  
  
  // numeric_limits<bool> specialization.
  template <>
  struct numeric_limits<bool>
  {
    __host__ __device__
    static bool min() throw()
    { return false;}
    __host__ __device__
    static bool max() throw()
    { return true;}
  };

  // numeric_limits<signed char> specialization.
  template <>
  struct numeric_limits<signed char>
  {
    __host__ __device__
    static signed char min() throw()
    { return -__SCHAR_MAX__ - 1;}
    __host__ __device__
    static signed char max() throw()
    { return __SCHAR_MAX__;}
  };

  // numeric_limits<unsigend char> spacialization.
  template <>
  struct numeric_limits<unsigned char>
  {
    __host__ __device__
    static unsigned char min() throw()
    { return 0;}
    __host__ __device__
    static unsigned char max() throw()
    { return __SCHAR_MAX__ * 2U + 1;}
  };
  
  // numric_limits<short> specialization.
  template <>
  struct numeric_limits<short>
  {
    __host__ __device__
    static short min() throw()
    { return -__SHRT_MAX__ - 1;}
    __host__ __device__
    static short max() throw()
    { return __SHRT_MAX__;}
  };

  // numeric_limits<unsigned short> specialization.
  template <>
  struct numeric_limits<unsigned short>
  {
    __host__ __device__
    static unsigned short min() throw() 
    { return 0;}
    __host__ __device__
    static unsigned short max() throw()
    { return __SHRT_MAX__ * 2U + 1;}
  };

  // numeric_limits<int> specialization.
  template <>
  struct numeric_limits<int>
  {
    __host__ __device__
    static int min() throw()
    { return -__INT_MAX__ - 1;}
    __host__ __device__
    static int max() throw()
    { return __INT_MAX__;}
  };

  // numeric_limits<unsigned int> specialization.
  template <>
  struct numeric_limits<unsigned int>
  {
    __host__ __device__
    static unsigned int min() throw()
    { return 0;}
    __host__ __device__
    static unsigned int max() throw()
    { return __INT_MAX__ * 2U + 1;}
  };

  // numeric_limits<long> specialization.
  template <>
  struct numeric_limits<long>
  {
    __host__ __device__
    static long min() throw()
    { return -__LONG_MAX__ - 1;}
    __host__ __device__
    static long max() throw()
    { return __LONG_MAX__;}
  };

  // numeric_limits<unsigned long> specialization.
  template <>
  struct numeric_limits<unsigned long>
  {
    __host__ __device__
    static unsigned long min() throw()
    { return 0;}
    __host__ __device__
    static unsigned long max() throw()
    { return __LONG_MAX__ * 2UL + 1;}
  };

  // numeric_limits<long long> specialization.
  template <>
  struct numeric_limits<long long>
  {
    static long long min() throw()
    { return -__LONG_LONG_MAX__ - 1;}
    static long long max() throw()
    { return __LONG_LONG_MAX__;}
  };

  // numeric_limits<unsigned long long> specialization.
  template <>
  struct numeric_limits<unsigned long long>
  {
    __host__ __device__
    static unsigned long long min() throw()
    { return 0;}
    __host__ __device__
    static unsigned long long max() throw()
    { return __LONG_LONG_MAX__ * 2ULL + 1;}
  };

  // numeric_limits<float> specialization.
  template <>
  struct numeric_limits<float>
  {
    __host__ __device__
    static float min() throw()
    { return __FLT_MIN__;}
    __host__ __device__
    static float max() throw()
    { return __FLT_MAX__;}
  };

  // numeric_limits<double> specialization.
  template <>
  struct numeric_limits<double>
  {
    __host__ __device__
    static double min() throw()
    { return __DBL_MIN__;}
    __host__ __device__
    static double max() throw()
    { return __DBL_MAX__;}
  };

  // numeric_limits<long double> specialization.
  template <>
  struct numeric_limits<long double>
  {
    __host__ __device__
    static long double min() throw()
    { return __LDBL_MIN__;}
    __host__ __device__
    static long double max() throw()
    { return __LDBL_MAX__;}
  };
} // end namespace thrust
